package com.darwin.darwinMVC.core
{
	public class CmdNameList
	{
		public function CmdNameList(...rest)
		{
			_nameList = rest;
		}
		
		private var _nameList:Array;
		
		public function get nameList():Array
		{
			return _nameList;
		}
		
		
		/**
		 * 判断一个name是否在这个列表中存在
		 * 
		 */
		public function exist(name:String):Boolean
		{
			for (var i:int = 0; i < nameList.length; i++) 
			{
				if (nameList[i] == name) 
				{
					return true;
				}
			}
			return false;
		}
		
		
		/**
		 * 判断两个CmdNameList对象是否相等
		 * @param cmdNameList CmdNameList对象
		 * @return 相等为true,不相等为flase
		 */
		public function contrast(cmdNameList:CmdNameList):Boolean
		{
			if(cmdNameList.nameList.length != nameList.length)
			{
				return false;
			}
			for(var i:int = 0;i<cmdNameList.nameList.length;i++)
			{
				var b:Boolean = false;
				for(var j:int = 0;j<nameList.length;j++)
				{
					if(cmdNameList.nameList[i] == nameList[j])
					{
						b = true;
					}
				}
				if(b == false)
				{
					return false;
				}
			}
			return true;
		}
		
	}
}